package o;

import android.content.Context;
import android.graphics.Matrix;
import android.view.TextureView;
import android.view.View.MeasureSpec;

public class evz extends TextureView {
    private boolean ˊ = false;
    private int ˋ;
    private int ˎ;
    private int ˏ;
    private int ॱ;
    private Matrix ॱॱ;

    public evz(Context context) {
        super(context);
    }

    public void ˊ(int i, int i2) {
        if (this.ˏ != i && this.ˋ != i2) {
            this.ˏ = i;
            this.ˋ = i2;
            if (this.ˊ) {
                this.ˎ = getWidth();
                this.ॱ = getHeight();
                this.ॱॱ = getMatrix();
                ˎ();
                return;
            }
            requestLayout();
        }
    }

    public void setCenterCrop(boolean z) {
        this.ˊ = z;
    }

    public void setOriginalMatrix() {
        if (this.ॱॱ != null) {
            setTransform(this.ॱॱ);
        }
    }

    public void setRotation(float f) {
        if (Math.abs(f - getRotation()) > 1.0f) {
            super.setRotation(f);
            requestLayout();
            invalidate();
        }
    }

    protected void onMeasure(int i, int i2) {
        if (this.ˊ) {
            super.onMeasure(i, i2);
            return;
        }
        float rotation = getRotation();
        if (rotation == 90.0f || rotation == 270.0f) {
            int i3 = i;
            i = i2;
            i2 = i3;
        }
        ॱ(i, i2);
    }

    private void ॱ(int i, int i2) {
        Object obj = 1;
        int defaultSize = getDefaultSize(this.ˏ, i);
        int defaultSize2 = getDefaultSize(this.ˋ, i2);
        if (this.ˏ > 0 && this.ˋ > 0) {
            int mode = MeasureSpec.getMode(i);
            defaultSize = MeasureSpec.getSize(i);
            int mode2 = MeasureSpec.getMode(i2);
            defaultSize2 = MeasureSpec.getSize(i2);
            if (mode == 1073741824 && mode2 == 1073741824) {
                if (this.ˏ * defaultSize2 < this.ˋ * defaultSize) {
                    defaultSize = (this.ˏ * defaultSize2) / this.ˋ;
                } else if (this.ˏ * defaultSize2 > this.ˋ * defaultSize) {
                    defaultSize2 = (this.ˋ * defaultSize) / this.ˏ;
                }
            } else if (mode == 1073741824) {
                r1 = (this.ˋ * defaultSize) / this.ˏ;
                if (mode2 != Integer.MIN_VALUE || r1 <= defaultSize2) {
                    obj = null;
                }
                if (obj != null) {
                    r1 = (this.ˏ * defaultSize2) / this.ˋ;
                } else {
                    defaultSize2 = r1;
                    r1 = defaultSize;
                }
                defaultSize = r1;
            } else {
                if (mode2 == 1073741824) {
                    r1 = (this.ˏ * defaultSize2) / this.ˋ;
                    if (mode != Integer.MIN_VALUE || r1 <= defaultSize) {
                        obj = null;
                    }
                    if (obj != null) {
                        defaultSize2 = (this.ˋ * defaultSize) / this.ˏ;
                    }
                } else {
                    int i3 = this.ˏ;
                    r1 = this.ˋ;
                    Object obj2 = (mode2 != Integer.MIN_VALUE || r1 <= defaultSize2) ? null : 1;
                    if (obj2 != null) {
                        r1 = (this.ˏ * defaultSize2) / this.ˋ;
                    } else {
                        defaultSize2 = r1;
                        r1 = i3;
                    }
                    if (mode != Integer.MIN_VALUE || r1 <= defaultSize) {
                        obj = null;
                    }
                    if (obj != null) {
                        defaultSize2 = (this.ˋ * defaultSize) / this.ˏ;
                    }
                }
                defaultSize = r1;
            }
        }
        setMeasuredDimension(defaultSize, defaultSize2);
    }

    public void ˎ() {
        float f = ((float) this.ˎ) / ((float) this.ˏ);
        float f2 = ((float) this.ॱ) / ((float) this.ˋ);
        Matrix matrix = new Matrix();
        f = Math.max(f, f2);
        matrix.preTranslate(((float) (this.ˎ - this.ˏ)) / 2.0f, ((float) (this.ॱ - this.ˋ)) / 2.0f);
        matrix.preScale(((float) this.ˏ) / ((float) this.ˎ), ((float) this.ˋ) / ((float) this.ॱ));
        matrix.postScale(f, f, ((float) this.ˎ) / 2.0f, ((float) this.ॱ) / 2.0f);
        setTransform(matrix);
    }
}
